package server.Handler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import util.LoginUtil;

public class AuthHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        if (LoginUtil.hasLogin(ctx.channel())) {
            System.out.println("当前用户已登录，后续无需验证");
            ctx.pipeline().remove(this);
            super.channelRead(ctx, msg);
        } else {
            System.out.println("当前用户未登录，已关闭连接");
            ctx.channel().close();
        }
    }
}
